<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'result.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
   <%
   String name1=request.getParameter("zhanghao");
   String word1=request.getParameter("mima");
   Connection conn=null;
   Statement sm=null;
   ResultSet rs=null;
   String url="jdbc:mysql://127.0.0.1:3306/mytest?useUnicode=true&amp;characterEncoding=utf-8";
   Class.forName("com.mysql.jdbc.Driver");
   String user="root";
   String pwd="x5";
   conn=(Connection) DriverManager.getConnection(url,user,pwd);
   sm=(Statement) conn.createStatement();
   StringBuilder sb=new StringBuilder("select user.zhanghao,user.mima from user");
   
   rs=(ResultSet) sm.executeQuery(sb.toString());
   while(rs.next()){
	 String name=rs.getString("zhanghao");
  	 String word=rs.getString("mima");
  	 if(name1==name&&word==word1){
  		System.out.println("欢迎您！");
  	 }
   }
  rs.close();
  sm.close();
  conn.close();
   %>
  </body>
</html>
